package com.example.artwindow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.artwindow.domain.po.Ad;
import com.example.artwindow.result.Result;
import com.example.artwindow.service.AdService;
import com.example.artwindow.mapper.AdMapper;
import org.apache.ibatis.jdbc.Null;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author EiEi
* @description 针对表【ad_info】的数据库操作Service实现
* @createDate 2024-04-26 10:23:00
*/
@Service
public class AdServiceImpl extends ServiceImpl<AdMapper, Ad>
    implements AdService{

	@Override
	public Result<List<Ad>> getAdList() {
		return Result.success(list(new LambdaQueryWrapper<Ad>().eq(Ad::getRecruit, 0).orderByDesc(Ad::getCreateTime).last("limit " + 5)));
	}

	@Override
	public Result<Null> AdUploadDTO(Ad ad) {
		save(ad);
		return Result.success();
	}

	@Override
	public Result<List<Ad>> listRecruit() {
		return Result.success(list(new LambdaQueryWrapper<Ad>().eq(Ad::getRecruit, 1).orderByDesc(Ad::getCreateTime).last("limit " + 9)));
	}


}




